package com.polelink.testcenter.exception;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.stream.Collectors;

public class DtcException extends RuntimeException {
    private static final Logger logger = LoggerFactory.getLogger("DTC_PARSER");
    public DtcException(String message) {
        super(message);
        logger.warn("[业务异常] {}，追踪信息：\n{}",
                message,
                Arrays.stream(getStackTrace())
                        .limit(5)
                        .map(StackTraceElement::toString)
                        .collect(Collectors.joining("\n")));
    }

    public DtcException(String message, Throwable cause) {
        super(message, cause);
        logger.warn("[业务异常] {} - 根因: {}\n堆栈追踪：\n{}",
                message,
                cause.getMessage(),
                Arrays.stream(cause.getStackTrace())
                        .limit(5)
                        .toArray());
    }
}
